package com.lanou.musicbox.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.lanou.musicbox.fragment.localmusic.LocalityFragment;
import com.lanou.musicbox.fragment.networkradio.NetworkRadioFragment;
import com.lanou.musicbox.fragment.onlinemusic.NetworkMusicFragment;
import com.lanou.musicbox.fragment.seekmusic.SeekMusicsFragment;

import java.util.ArrayList;

/**
 * Created by dllo on 15/10/26.
 */
public class MainFragmentAdapter extends FragmentStatePagerAdapter {
    private ArrayList<Fragment>datas;

    public MainFragmentAdapter(FragmentManager fm) {
        super(fm);
        initDatas();
    }

    private void initDatas() {
        datas = new ArrayList<>();
        datas.add(new LocalityFragment());
        datas.add(new NetworkMusicFragment());
        datas.add(new NetworkRadioFragment());
        datas.add(new SeekMusicsFragment());
    }

    @Override
    public Fragment getItem(int position) {
        return datas != null && datas.size() > 0 ? datas.get(position) : null;
    }

    @Override
    public int getCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }
}
